/* 
 * File:   plantstest.cpp
 * Author: dolphinigle
 *
 * Created on March 12, 2011, 8:10 PM
 */

#include <stdlib.h>
#include "gtest/gtest.h"
#include "dropbox.hpp"
#include "game.hpp"
#include "plantablecell.hpp"
#include "plants.hpp"
#include "plant.hpp"
#include "plantconstants.hpp"

TEST(PlantsTest, All) {

  Game* game = new Game("Irvan", "test.gag");
  PlantableCell* cell = new PlantableCell(game);
  Plant* plant = new Plant(game, cell, 0);
  Plants* plants = new Plants(game);
  
  EXPECT_FALSE(plants->containsPlantAt(cell));
  plants->addPlant(plant);
  EXPECT_TRUE(plants->containsPlantAt(cell));
  EXPECT_EQ(plant, plants->getPlantAt(cell));

  cell->water();

  for (int i = 0; i < PlantConstants::getPlantMatureTime(0); ++i) {
    plants->advanceDay();
  }
  EXPECT_TRUE(plant->isMature());
  EXPECT_TRUE(plants->containsPlantAt(cell));
  EXPECT_EQ(plant, plants->getPlantAt(cell));

  EXPECT_FALSE(plant->isDead());
  plants->makeAllDead();
  EXPECT_TRUE(plant->isDead());

  EXPECT_FALSE(plant->isSeed());
  plants->restartAllNotDeadToSeed();
  EXPECT_FALSE(plant->isSeed());

  plants->removePlant(plant);
  EXPECT_FALSE(plants->containsPlantAt(cell));

  delete plants;
  delete cell;
  delete game;

}

